load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("scm_client_infra")

cpp_library(
    name = "memory_priority",
    headers = ["MemoryPriority.h"],
)

cpp_library(
    name = "linux_memory_priority",
    srcs = ["LinuxMemoryPriority.cpp"],
    headers = ["LinuxMemoryPriority.h"],
    deps = [
        "//eden/common/utils:file_utils",
        "//eden/common/utils:path",
        "//eden/common/utils:throw",
        "//folly/logging:logging",
    ],
    exported_deps = [
        ":memory_priority",
    ],
)

cpp_library(
    name = "darwin_memory_priority",
    srcs = ["DarwinMemoryPriority.cpp"],
    headers = [
        "DarwinMemoryPriority.h",
        "private_headers/kern_memorystatus.h",
    ],
    deps = [
        "//eden/common/utils:throw",
        "//folly/logging:logging",
    ],
    exported_deps = [
        ":memory_priority",
    ],
)

cpp_library(
    name = "process_priority",
    srcs = ["ProcessPriority.cpp"],
    headers = ["ProcessPriority.h"],
    os_deps = [
        (
            "linux",
            [":linux_memory_priority"],
        ),
        (
            "macos",
            [":darwin_memory_priority"],
        ),
    ],
    deps = [
        ":darwin_memory_priority",
        ":linux_memory_priority",
        "//folly/logging:logging",
    ],
    exported_deps = [
        ":memory_priority",
        "//folly:portability",
        "//folly/portability:sys_types",
    ],
)
